ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Partridge_Male Class Reference

The partridge male class. More...

#include <Partridge_All.h>

Inheritance diagram for Partridge_Male:
Partridge_Base TAnimal TALMaSSObject

Public Member Functions

int AmIaMember ()
 A debug function. More...
 
virtual void Dying ()
 General dying handler. More...
 
virtual void BeginStep (void)
 Male BeginStep. More...
 
virtual void Step (void)
 Male Step. More...
 
virtual void EndStep (void)
 Male EndStep. More...
 
virtual bool DailyMortality ()
 Background mortality check. More...
 
virtual bool OnFarmEvent (FarmToDo event)
 Management event handler. More...
 
virtual void KillThis ()
 General direct mortality handler. More...
 
void UnSetMate (void)
 remove mate pointer More...
 
virtual bool ArePaired ()
 Are we paired? More...
 
Partridge_FemaleGetMate (void)
 Are we paired? More...
 
 Partridge_Male (int a_born_x, int a_born_y, int a_x, int a_y, Partridge_Covey *a_flock, Landscape *a_map, int a_family_counter, Partridge_Population_Manager *a_manager)
 Constructor. More...
 
virtual ~Partridge_Male (void)
 Destructor. More...
 
void OnLookAfterKids (void)
 Message handler. More...
 
void StartBreedingBehaviour (void)
 Message handler. More...
 
void OnMating (Partridge_Female *a_mate)
 Message handler. More...
 
void OnMateDying ()
 Message handler. More...
 
void OnFoundATerrtitory ()
 Message handler. More...
 
void OnChicksMatured ()
 Message handler. More...
 
void OnChicksDead ()
 Message handler. More...
 
void OnStoppingBreeding ()
 Message handler. More...
 
void OnFemaleGivingUp ()
 Message handler. More...
 
void OnMovingHome ()
 Message handler. More...
 
void SetOldMate (Partridge_Female *pf)
 Set old mate pointer. More...
 
Partridge_FemaleGetOldMate (void)
 Supply old mate pointer. More...
 
void RemoveOldMate (bool a_knockon)
 Forget any old mate. More...
 
- Public Member Functions inherited from Partridge_Base
Partridge_Object GetObjectType ()
 Supply object type. More...
 
bool GetUncleStatus ()
 Supply uncle status. More...
 
void SetUncleStatus (bool a_Status)
 Set uncle status. More...
 
bool PossibleMate (Partridge_Base *a_partridge)
 Can we mate? More...
 
Partridge_CoveyGetCovey (void)
 Supply covey pointer. More...
 
Partridge_State GetState (void)
 Supply state. More...
 
void SetState (Partridge_State a_pars)
 Set state. More...
 
int GetFamily (void)
 Supply family ID. More...
 
int GetAge (void)
 Supply age. More...
 
void SetAge (int a_age)
 Set age. More...
 
long GetID (void)
 Supply ID. More...
 
void SetFamily (unsigned int family)
 Set family ID. More...
 
void SetCovey (Partridge_Covey *a_covey)
 Set covey pointer. More...
 
void MakeCovey ()
 Create our own covey. More...
 
void SwitchCovey (Partridge_Covey *a_covey)
 Swap coveys. More...
 
 Partridge_Base (int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey *a_covey, Landscape *a_map, Partridge_Population_Manager *a_manager)
 Constructor for Partridge_Base. More...
 
virtual ~Partridge_Base (void)
 Destructor. More...
 
virtual void CopyMyself (int a_Ptype)
 Duplicate this object. More...
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual int WhatState ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Private Member Functions

Partridge_State MFlocking (void)
 State male flocking. More...
 
Partridge_State MFindingMate (void)
 State male finding mate. More...
 
Partridge_State MPairing (void)
 State male pairing. More...
 
Partridge_State MGuardingMate (void)
 State male guarding mate. More...
 
Partridge_State MCaringForYoung (void)
 State male caring for young. More...
 
Partridge_State MFollowingMate (void)
 State male follow mate. More...
 
void MDying (void)
 State male dying. More...
 
virtual void CheckMatePointers ()
 A debug function. More...
 

Private Attributes

int m_lifespan
 Physiological lifespan. More...
 
Partridge_Femalem_MyOldWife
 Old mate pointer. More...
 
Partridge_Femalem_MyMate
 Current mate pointer. More...
 

Additional Inherited Members

- Public Attributes inherited from Partridge_Base
Partridge_Population_Managerm_OurPopulationManager
 Pointer to the population manager. More...
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 
- Protected Attributes inherited from Partridge_Base
int m_signal
 Used to pass information to outputs. More...
 
long m_id
 Individual bird ID. More...
 
int m_family_counter
 Family ID. More...
 
int m_age
 Age in days. More...
 
int m_born_x
 x-coord of birth More...
 
int m_born_y
 y-coord of birth More...
 
bool m_UncleStatus
 If has uncle status in the covey. More...
 
Partridge_Object m_object_type
 Type of pob object this is. More...
 
Partridge_Coveym_covey
 Pointer to the covey. More...
 
Partridge_State m_state
 Current behavioural state. More...
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Detailed Description

The partridge male class.

Constructor & Destructor Documentation

◆ Partridge_Male()

Partridge_Male::Partridge_Male ( int  a_born_x,
int  a_born_y,
int  a_x,
int  a_y,
Partridge_Covey a_flock,
Landscape a_map,
int  a_family_counter,
Partridge_Population_Manager a_manager 
)

Constructor.

2184  :
2185  Partridge_Base( a_born_x, a_born_y, a_x, a_y, a_family_counter, a_covey, a_map, a_manager )
2186  {
2187  m_MyOldWife=NULL; // Cant call removeOldMate due to knock on effects
2188  m_MyMate = NULL;
2191  //m_visitors_pass = false;
2192 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
CfgInt cfg_par_min_lifespan("PAR_MIN_LIFESPAN", CFG_CUSTOM, 1825)
Minimum physiological lifespan.
CfgInt cfg_par_max_lifespan("PAR_MAX_LIFESPAN", CFG_CUSTOM, 3650)
Maximum physiological lifespan.
@ pob_Male
Definition: Partridge_All.h:297
int value(void)
Definition: configurator.h:98
Partridge_Object m_object_type
Type of pob object this is.
Definition: Partridge_All.h:418
Partridge_Base(int a_born_x, int a_born_y, int a_x, int a_y, int a_family_counter, Partridge_Covey *a_covey, Landscape *a_map, Partridge_Population_Manager *a_manager)
Constructor for Partridge_Base.
Definition: Partridge_All.cpp:156
Partridge_Female * m_MyOldWife
Old mate pointer.
Definition: Partridge_All.h:676
int m_lifespan
Physiological lifespan.
Definition: Partridge_All.h:674
Partridge_Female * m_MyMate
Current mate pointer.
Definition: Partridge_All.h:678

References cfg_par_max_lifespan, cfg_par_min_lifespan, m_lifespan, m_MyMate, m_MyOldWife, Partridge_Base::m_object_type, pob_Male, random(), and CfgInt::value().

◆ ~Partridge_Male()

virtual Partridge_Male::~Partridge_Male ( void  )
inlinevirtual

Destructor.

728 {;}

Member Function Documentation

◆ AmIaMember()

int Partridge_Male::AmIaMember ( )

A debug function.

A debug function.

3160 {
3161  if ( m_covey->GetCurrentStateNo() == -1 )
3162  {
3163  //exit(0);
3164  return 1;
3165  }
3166  if ( !m_covey->IsMember( this ) ) return 2;
3167  return 0;
3168 }
Partridge_Covey * m_covey
Pointer to the covey.
Definition: Partridge_All.h:420
bool IsMember(Partridge_Base *a_possible_member)
Definition: Partridge_Covey.cpp:1709
int GetCurrentStateNo()
Returns the current state number.
Definition: PopulationManager.h:121

References TALMaSSObject::GetCurrentStateNo(), Partridge_Covey::IsMember(), and Partridge_Base::m_covey.

Referenced by Partridge_Population_Manager::DoMaleSanityCheck().

◆ ArePaired()

virtual bool Partridge_Male::ArePaired ( )
inlinevirtual

Are we paired?

Reimplemented from Partridge_Base.

713  {
714  if (m_MyMate!=NULL) return true;
715  return false;
716  }

References m_MyMate.

◆ BeginStep()

void Partridge_Male::BeginStep ( void  )
virtual

Male BeginStep.

The BeginStep code for the male partridge. Its only function is the test for mortality of different kinds. Might as well remove him here than waste CPU time thinking about the Step code later this time-step.

Reimplemented from TAnimal.

2203 {
2204 #ifdef __PAR_DEBUG
2206 #endif
2207  m_age++; // Get a day older
2208  if ( m_age >= m_lifespan )
2209  {
2210  m_signal = 0;
2211  MDying();
2212  }
2213  else if ( !DailyMortality() ) CheckManagement();
2214  else
2215  {
2216  m_signal = 1;
2217  MDying();
2218  }
2219 #ifdef __PAR_DEBUG
2221 #endif
2222 }
int m_age
Age in days.
Definition: Partridge_All.h:410
int m_signal
Used to pass information to outputs.
Definition: Partridge_All.h:404
virtual void CheckMatePointers()
A debug function.
Definition: Partridge_All.cpp:2800
void MDying(void)
State male dying.
Definition: Partridge_All.cpp:2630
virtual bool DailyMortality()
Background mortality check.
Definition: Partridge_All.cpp:2446
void CheckManagement(void)
Definition: PopulationManager.cpp:1404

References TAnimal::CheckManagement(), CheckMatePointers(), DailyMortality(), Partridge_Base::m_age, m_lifespan, Partridge_Base::m_signal, and MDying().

◆ CheckMatePointers()

void Partridge_Male::CheckMatePointers ( )
privatevirtual

A debug function.

This is a debug function.

Reimplemented from Partridge_Base.

2801 {
2802  //**CJT** DEBUG
2803  if ( m_MyMate )
2804  {
2805  // Check for mutual pointers here
2806  if ( m_MyMate->GetMate() != this )
2807  {
2808  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Non-mutual mate pointers", "" );
2809  exit( 1 );
2810  }
2811  if ( m_state == pars_MFlocking )
2812  {
2813  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Mated & Flocking", "" );
2814  exit( 1 );
2815  }
2816  if ( m_MyMate->GetCurrentStateNo() == -1 )
2817  {
2818  m_OurLandscape->Warn( "Partridge_Male::CheckMatePointers(): ""Dead Mate", "" );
2819  exit( 1 );
2820  }
2821  }
2822 }
@ pars_MFlocking
Definition: Partridge_All.h:279
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
Partridge_State m_state
Current behavioural state.
Definition: Partridge_All.h:422
Partridge_Male * GetMate(void)
Supply mate pointer.
Definition: Partridge_All.h:872
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References TALMaSSObject::GetCurrentStateNo(), Partridge_Female::GetMate(), m_MyMate, TAnimal::m_OurLandscape, Partridge_Base::m_state, pars_MFlocking, and Landscape::Warn().

Referenced by BeginStep(), MFindingMate(), MFollowingMate(), MPairing(), OnFemaleGivingUp(), OnLookAfterKids(), OnMateDying(), OnMating(), and Step().

◆ DailyMortality()

bool Partridge_Male::DailyMortality ( void  )
virtual

Background mortality check.

Test for background mortality - identical to the female except that the male responds to female activity.

Reimplemented from Partridge_Base.

2447 {
2448 
2449  double chance = g_rand_uni();
2450  double extramort=1.0;
2451 
2452 // extra mortality chance if in a covey alone
2453  if ( m_covey->GetCoveySize() == 1 )
2454  {
2456  }
2457  // Winter mortality between April and Sept
2458  int today = m_OurLandscape->SupplyDayInYear();
2459  // If the female is looking for a territory then the mortality is higher
2460  if (m_MyMate!=NULL) {
2462  if ( chance < cfg_par_adult_mortalitySpring.value() ) return true;
2463  return false;
2464  }
2465  }
2466  // Is it winter?
2467  if (( ( today >= October ) || ( today < April )) ) {
2468  if (m_OurPopulationManager->SupplyShouldFlock()) { // We are in the "Winter Period"
2469  if ( chance < cfg_par_adult_mortalityWinter.value()*extramort ) {
2470  return true;
2471  } else return false;
2472  } else { // Finding territory value
2473  if ( chance < cfg_par_adult_mortalitySpring.value()*extramort ) {
2474  return true;
2475  } else return false;
2476  }
2477  } else // Not winter and not finding territory
2478  {
2479  if ( chance < (cfg_par_adult_mortalitySummer.value()*extramort) ) return true;
2480  }
2481  return false;
2482 
2483 }
static CfgFloat cfg_par_adult_mortalitySummer("PAR_ADULT_MORTALITYSUMMER", CFG_CUSTOM, 0.0001)
Adults - daily probability of non-explicitly modelled mortality in Summer.
boost::variate_generator< base_generator_type &, boost::uniform_real<> > g_rand_uni
static CfgFloat cfg_par_adult_mortalityWinter("PAR_ADULT_MORTALITYWINTER", CFG_CUSTOM, 0.0217)
Adults - daily probability of non-explicitly modelled mortality in Winter.
static CfgFloat cfg_par_adult_mortalitySpring("PAR_ADULT_MORTALITYSPRING", CFG_CUSTOM, 0.0096)
Adults - daily probability of non-explicitly modelled mortality in Spring.
static CfgFloat cfg_par_adult_mortality_alone("PAR_ADULT_MORTALITY_ALONE", CFG_CUSTOM, 1.4)
Adults - extra mortality scaler if alone.
@ pars_FFindingTerritory
Definition: Partridge_All.h:282
double value(void)
Definition: configurator.h:118
int SupplyDayInYear(void)
Definition: landscape.h:1596
Partridge_Population_Manager * m_OurPopulationManager
Pointer to the population manager.
Definition: Partridge_All.h:430
unsigned int GetCoveySize()
Return the covey size.
Definition: Partridge_Covey.h:476
bool SupplyShouldFlock()
Definition: Partridge_Population_Manager.h:286
virtual int WhatState()
Definition: PopulationManager.h:263
const int October
Definition: landscape.h:45
const int April
Definition: landscape.h:39

References April, cfg_par_adult_mortality_alone, cfg_par_adult_mortalitySpring, cfg_par_adult_mortalitySummer, cfg_par_adult_mortalityWinter, g_rand_uni, Partridge_Covey::GetCoveySize(), Partridge_Base::m_covey, m_MyMate, TAnimal::m_OurLandscape, Partridge_Base::m_OurPopulationManager, October, pars_FFindingTerritory, Landscape::SupplyDayInYear(), Partridge_Population_Manager::SupplyShouldFlock(), CfgFloat::value(), and TAnimal::WhatState().

Referenced by BeginStep().

◆ Dying()

virtual void Partridge_Male::Dying ( )
inlinevirtual

General dying handler.

Reimplemented from TAnimal.

687  {
688  MDying();
689  }

References MDying().

◆ EndStep()

void Partridge_Male::EndStep ( void  )
virtual

Male EndStep.

Male EndStep - nothing to do here. Currently just checks for unknown states.

Reimplemented from TAnimal.

2286 {
2287  switch ( m_state )
2288  {
2289  case pars_Initiation:
2290  case pars_MFlocking:
2291  case pars_MFindingMate:
2292  case pars_MPairing:
2293  case pars_MGuardingMate:
2294  case pars_MFollowingMate:
2295  case pars_MCaringForYoung:
2296  case pars_MDying:
2297  case pars_Destroy:
2298  break;
2299  default:
2300  m_OurLandscape->Warn( "Partridge_Male::EndStep - unknown pars type", NULL );
2301  exit( 1 );
2302  }
2303 }
@ pars_MDying
Definition: Partridge_All.h:279
@ pars_MCaringForYoung
Definition: Partridge_All.h:279
@ pars_Destroy
Definition: Partridge_All.h:287
@ pars_MFollowingMate
Definition: Partridge_All.h:279
@ pars_MFindingMate
Definition: Partridge_All.h:279
@ pars_MPairing
Definition: Partridge_All.h:279
@ pars_MGuardingMate
Definition: Partridge_All.h:279
@ pars_Initiation
Definition: Partridge_All.h:267

References TAnimal::m_OurLandscape, Partridge_Base::m_state, pars_Destroy, pars_Initiation, pars_MCaringForYoung, pars_MDying, pars_MFindingMate, pars_MFlocking, pars_MFollowingMate, pars_MGuardingMate, pars_MPairing, and Landscape::Warn().

◆ GetMate()

◆ GetOldMate()

Partridge_Female* Partridge_Male::GetOldMate ( void  )
inline

Supply old mate pointer.

757  {
758  return m_MyOldWife;
759  }

References m_MyOldWife.

Referenced by Partridge_Communication::PassMessage().

◆ KillThis()

virtual void Partridge_Male::KillThis ( void  )
inlinevirtual

General direct mortality handler.

Reimplemented from TAnimal.

703  {
704  MDying();
705  }

References MDying().

Referenced by Partridge_Population_Manager::DoFirst().

◆ MCaringForYoung()

Partridge_State Partridge_Male::MCaringForYoung ( void  )
private

State male caring for young.

This simple ensures that there is a call to a foraging movement, the size of which is dependent upon the age of the young.

2618 {
2619  // dist move is calculated as a function of chick food need-
2620  // First get the chick age
2621  int ch_age = m_covey->GetChickAge();
2622  m_covey->MoveDistance( g_MaxWalk[ch_age], 10, 10000 );
2623  return pars_MCaringForYoung;
2624 }
int g_MaxWalk[200]
Definition: Partridge_Population_Manager.cpp:66
int GetChickAge()
Return chick age.
Definition: Partridge_Covey.h:486
void MoveDistance(int a_max_distance, int a_step_size, double a_food_density_needed)
Entry point for movement.
Definition: Partridge_Covey.cpp:652

References g_MaxWalk, Partridge_Covey::GetChickAge(), Partridge_Base::m_covey, Partridge_Covey::MoveDistance(), and pars_MCaringForYoung.

Referenced by Step().

◆ MDying()

void Partridge_Male::MDying ( void  )
private

State male dying.

Do the housekeeping for dying.

2631 {
2632 
2633  if ( m_CurrentStateNo != -1 )
2634  { // Don't kill me twice
2635  // Tell my mate if I have one
2636  if ( m_MyMate )
2637  {
2638  // The line below is really debug information, this identifies the caller
2640  // Call the female via the message centre
2643  m_MyMate = NULL;
2644  }
2645  RemoveOldMate(false);
2646  m_CurrentStateNo = -1;
2647  m_StepDone = true;
2648  //m_covey->SanityCheck2(m_covey->GetOurChicks() );
2649 
2650  m_covey->RemoveMember( this );
2653  // m_OurPopulationManager->WriteParAdMort( m_OurLandscape->SupplyGlobalDate(), m_age, 0, m_signal );
2654  }
2655 }
@ pcomm_MaleDying
Definition: Partridge_Communication.h:55
bool PassMessage(PartridgeCommunicationData *pc_data, TypeOfPartridge_Communication pc)
Pass a message.
Definition: Partridge_Communication.cpp:86
int RemoveMember(Partridge_Base *a_former_member)
Remove a member from the covey.
Definition: Partridge_Covey.cpp:1664
void RemoveOldMate(bool a_knockon)
Forget any old mate.
Definition: Partridge_All.cpp:2661
k_factors * m_Ourkfactors
Pointer to kfactors object.
Definition: Partridge_Population_Manager.h:169
Partridge_Communication m_messagecentre
Message class pointer.
Definition: Partridge_Population_Manager.h:163
PartridgeCommunicationData * m_comms_data
Message data.
Definition: Partridge_Population_Manager.h:161
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116
population_attributes * m_ThisYear
Definition: Partridge_All.h:251
void incNoDeadMales()
Definition: Partridge_All.h:176
Partridge_Female * m_female
Definition: Partridge_Communication.h:84
Partridge_Male * m_male
Definition: Partridge_Communication.h:83

References population_attributes::incNoDeadMales(), Partridge_Population_Manager::m_comms_data, Partridge_Base::m_covey, TALMaSSObject::m_CurrentStateNo, PartridgeCommunicationData::m_female, PartridgeCommunicationData::m_male, Partridge_Population_Manager::m_messagecentre, m_MyMate, Partridge_Population_Manager::m_Ourkfactors, Partridge_Base::m_OurPopulationManager, Partridge_Base::m_state, TALMaSSObject::m_StepDone, k_factors::m_ThisYear, pars_Destroy, Partridge_Communication::PassMessage(), pcomm_MaleDying, Partridge_Covey::RemoveMember(), and RemoveOldMate().

Referenced by BeginStep(), Dying(), KillThis(), and OnFarmEvent().

◆ MFindingMate()

Partridge_State Partridge_Male::MFindingMate ( void  )
private

State male finding mate.

Caused by being unpaired on covey dissolve, he must find a mate. If the date is early then he'll try to hop into a nearby covey to find a mate if there is one. Later he goes on a more desparate search alone (which incurs a higher mortality if unsuccessful see Partridge_Male::DailyMortality.

2500 {
2501  if ( m_UncleStatus )
2502  {
2503  // This is no good - he can't stay an uncle anymore - must leave
2504  m_covey->RemoveMember( this );
2505  MakeCovey();
2506  m_UncleStatus = false; // just in case
2507  return pars_MFlocking; // this will send him back here eventually.
2508  }
2510  {
2511  m_UncleStatus = false; // just in case
2512  m_covey->SetFixed( false ); // ensure we do not have a fixed territory loc
2513  //}
2514  return pars_MFlocking;
2515  }
2516  // Depends on the date what happens.
2517  // If early then he will keep hopping if possible, if late and breeding is
2518  // starting then he must wander.
2519  //
2521  {
2522  // Still early so we need a list of possible coveys to hop to
2524  {
2526  if ( pc )
2527  {
2529  if ( m_MyMate )
2530  {
2531  m_covey->RemoveMember( this ); // NB the next two lines MUST come after a call to RemoveMember for adults if they are not dying
2532  m_UncleStatus = false;
2533  MakeCovey(); // Has his own now.
2534  }
2535  }
2536  }
2537  }
2538  else
2539  {
2540  // Must leave the covey he is with if he is not already alone
2541  if ( m_covey->GetCoveySize() > 1 )
2542  {
2543  m_covey->RemoveMember( this );
2544 // m_visitors_pass = false;
2545  m_UncleStatus = false;
2546  MakeCovey();
2547  }
2550  }
2551  // If he has found a mate he will have made his covey and now calls her to him
2552  if ( m_MyMate ) {
2553  // The line below is really debug information, this identifies the caller
2555  // Call the female via the message centre
2558  // This message also sets the females covey to the male's
2560 #ifdef __PAR_DEBUG
2562 #endif
2563  if ( !m_MyMate->HaveTerritory() ) return pars_MFollowingMate;
2564  return pars_MGuardingMate;
2565  }
2566  return pars_MFindingMate;
2567 }
CfgInt cfg_par_start_dissolve("PAR_START_DISSOLVE", CFG_CUSTOM, 30)
The earliest covey dissolve date.
Definition: Partridge_Population_Manager.cpp:94
static CfgInt cfg_par_MaleMateSearchArea("PAR_MALEMATESEARCHAREA", CFG_CUSTOM, 500)
Male mate searching radius.
static CfgInt cfg_par_MaleFlyingDistance("PAR_MALEFLYINGDISTANCE", CFG_CUSTOM, 2000)
The maximum flying distance for males.
@ pcomm_Mating
Definition: Partridge_Communication.h:57
void MakeCovey()
Create our own covey.
Definition: Partridge_All.cpp:206
int m_family_counter
Family ID.
Definition: Partridge_All.h:408
bool m_UncleStatus
If has uncle status in the covey.
Definition: Partridge_All.h:416
The collective for a family of partridges
Definition: Partridge_Covey.h:90
Partridge_Female * FindMateInArea(int a_max_distance)
Find mate in area.
Definition: Partridge_Covey.cpp:1561
Partridge_Covey * FindNeighbour()
Finds the closest other covey.
Definition: Partridge_Covey.cpp:2290
bool FlyTo(int a_distance)
Fly to
Definition: Partridge_Covey.cpp:1484
Partridge_Female * FindMeAMateInCovey(int a_family_counter)
Is their a suitable female mate in the covey?
Definition: Partridge_Covey.cpp:2334
void SetFixed(bool a_is_fixed)
Prevent/enable peg drift.
Definition: Partridge_Covey.h:572
bool HaveTerritory(void)
Have we a breeding 'territory'?
Definition: Partridge_All.h:920
bool FillCoveyNeigbourList(Partridge_Covey *a_covey, int a_distance, int a_x, int a_y)
Get a list of neighbour covies.
Definition: Partridge_Population_Manager.cpp:1571
int m_Location_y
Definition: PopulationManager.h:228
int m_Location_x
Definition: PopulationManager.h:225
Partridge_Covey * m_covey
Definition: Partridge_Communication.h:85

References cfg_par_MaleFlyingDistance, cfg_par_MaleMateSearchArea, cfg_par_start_dissolve, CheckMatePointers(), Partridge_Population_Manager::FillCoveyNeigbourList(), Partridge_Covey::FindMateInArea(), Partridge_Covey::FindMeAMateInCovey(), Partridge_Covey::FindNeighbour(), Partridge_Covey::FlyTo(), Partridge_Covey::GetCoveySize(), Partridge_Female::HaveTerritory(), Partridge_Population_Manager::m_comms_data, Partridge_Base::m_covey, PartridgeCommunicationData::m_covey, Partridge_Base::m_family_counter, PartridgeCommunicationData::m_female, TAnimal::m_Location_x, TAnimal::m_Location_y, PartridgeCommunicationData::m_male, Partridge_Population_Manager::m_messagecentre, m_MyMate, TAnimal::m_OurLandscape, Partridge_Base::m_OurPopulationManager, Partridge_Base::m_UncleStatus, Partridge_Base::MakeCovey(), pars_MFindingMate, pars_MFlocking, pars_MFollowingMate, pars_MGuardingMate, Partridge_Communication::PassMessage(), pcomm_Mating, Partridge_Covey::RemoveMember(), Partridge_Covey::SetFixed(), Landscape::SupplyDayInYear(), Partridge_Population_Manager::SupplyShouldFlock(), and CfgInt::value().

Referenced by Step().

◆ MFlocking()

Partridge_State Partridge_Male::MFlocking ( void  )
private

State male flocking.

Flocking. Do Nothing but wait for the covey to tell us OnStartBreedingBehaviour

2490 {
2491  m_covey->MoveDistance( 1000, 10, 10000 );
2492  return pars_MFlocking;
2493 }

References Partridge_Base::m_covey, Partridge_Covey::MoveDistance(), and pars_MFlocking.

Referenced by Step().

◆ MFollowingMate()

Partridge_State Partridge_Male::MFollowingMate ( void  )
private

State male follow mate.

Will enter this state if he is paired, but the female has not yet found a territory.
Waits here until the mate has found a territory

2588 {
2593 #ifdef __PAR_DEBUG
2595 
2596 #endif
2597  if ( !m_MyMate->HaveTerritory() ) return pars_MFollowingMate;
2598  return pars_MGuardingMate;
2599 }

References CheckMatePointers(), Partridge_Female::HaveTerritory(), m_MyMate, pars_MFollowingMate, and pars_MGuardingMate.

Referenced by Step().

◆ MGuardingMate()

Partridge_State Partridge_Male::MGuardingMate ( void  )
private

State male guarding mate.

He will sit here until he is told to do otherwise - either mate dead, eggs have hatched or female given up.

2606 {
2610  return pars_MGuardingMate;
2611 }

References pars_MGuardingMate.

Referenced by Step().

◆ MPairing()

Partridge_State Partridge_Male::MPairing ( void  )
private

State male pairing.

If he has a territory then he is must go to mate guarding otherwise he must carry on and find one by following her lead.

2577 {
2578 #ifdef __PAR_DEBUG
2580 
2581 #endif
2582  if ( m_MyMate->HaveTerritory() ) return pars_MGuardingMate;
2583  return pars_MFollowingMate;
2584 }

References CheckMatePointers(), Partridge_Female::HaveTerritory(), m_MyMate, pars_MFollowingMate, and pars_MGuardingMate.

Referenced by Step().

◆ OnChicksDead()

void Partridge_Male::OnChicksDead ( void  )

Message handler.

Response to pcomm_AllChicksDead message arriving when the last chick dies.

2690 {
2691  m_MyMate = NULL;
2693 }

References m_MyMate, Partridge_Base::m_state, and pars_MFlocking.

Referenced by Partridge_Communication::PassMessage().

◆ OnChicksMatured()

void Partridge_Male::OnChicksMatured ( void  )

Message handler.

Response to pcomm_ChicksMature message arriving when the last chick matures.

2700 {
2701  m_MyMate = NULL;
2703 }

References m_MyMate, Partridge_Base::m_state, and pars_MFlocking.

Referenced by Partridge_Communication::PassMessage().

◆ OnFarmEvent()

bool Partridge_Male::OnFarmEvent ( FarmToDo  event)
virtual

Management event handler.

Check for and respond to management events.

Reimplemented from TAnimal.

2310 {
2311  switch ( event )
2312  {
2313  case sleep_all_day:
2314  break;
2315  case autumn_plough:
2316  break;
2317  case autumn_harrow:
2318  break;
2319  case autumn_roll:
2320  break;
2321  case autumn_sow:
2322  break;
2323  case winter_plough:
2324  break;
2325  case deep_ploughing:
2326  break;
2327  case spring_plough:
2328  break;
2329  case spring_harrow:
2330  break;
2331  case spring_roll:
2332  break;
2333  case spring_sow:
2334  break;
2335  case fp_npks:
2336  break;
2337  case fp_npk:
2338  break;
2339  case fp_pk:
2340  break;
2341  case fp_liquidNH3:
2342  break;
2343  case fp_slurry:
2344  break;
2345  case fp_manganesesulphate:
2346  break;
2347  case fp_manure:
2348  break;
2349  case fp_greenmanure:
2350  break;
2351  case fp_sludge:
2352  break;
2353  case fa_npk:
2354  break;
2355  case fa_pk:
2356  break;
2357  case fa_slurry:
2358  break;
2359  case fa_ammoniumsulphate:
2360  break;
2361  case fa_manure:
2362  break;
2363  case fa_greenmanure:
2364  break;
2365  case fa_sludge:
2366  break;
2367  case glyphosate:
2368  case herbicide_treat:
2369  break;
2370  case growth_regulator:
2371  break;
2372  case fungicide_treat:
2373  break;
2374  case syninsecticide_treat:
2375  case insecticide_treat:
2376  case product_treat:
2377  break;
2378  case molluscicide:
2379  break;
2380  case row_cultivation:
2381  break;
2382  case strigling:
2383  if ( g_rand_uni() < 0.01 ) MDying();
2384  break;
2385  case hilling_up:
2386  break;
2387  case water:
2388  break;
2389  case swathing:
2390  break;
2391  case harvest:
2392  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2393  break;
2394  case cattle_out:
2395  break;
2396  case cattle_out_low:
2397  break;
2398  case cut_to_hay:
2399  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2400  break;
2401  case cut_to_silage:
2402  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2403  break;
2404  case straw_chopping:
2405  break;
2406  case hay_turning:
2407  break;
2408  case hay_bailing:
2409  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2410  break;
2411  case stubble_harrowing:
2412  break;
2414  break;
2415  case burn_straw_stubble:
2416  break;
2417  case mow:
2418  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2419  break;
2420  case cut_weeds:
2421  if ( g_rand_uni() < cfg_par_ad_cut.value() ) MDying();
2422  break;
2423  case pigs_out:
2424  break;
2425  case strigling_sow:
2426  if ( g_rand_uni() < 0.01 ) MDying();
2427  break;
2428  default:
2429  m_OurLandscape->Warn( "Skylark_Clutch::OnFarmEvent(): Unknown event type:", m_OurLandscape->EventtypeToString( event ) );
2430  exit( 1 );
2431  }
2432  // Must incorporate a test here in case the animal is dead - killing it twice
2433  // can be a bad idea
2434  if ( m_state == pars_Destroy ) return true;
2435  else
2436  return false;
2437 }
static CfgFloat cfg_par_ad_cut("PAR_AD_CUT_MORT", CFG_CUSTOM, 0.01)
Adult % mortality on cutting.
std::string EventtypeToString(int a_event)
Definition: Landscape.cpp:3918
@ burn_straw_stubble
Definition: treatment.h:92
@ autumn_harrow
Definition: treatment.h:37
@ swathing
Definition: treatment.h:81
@ fa_pk
Definition: treatment.h:62
@ winter_plough
Definition: treatment.h:42
@ strigling
Definition: treatment.h:77
@ fp_npks
Definition: treatment.h:48
@ glyphosate
Definition: treatment.h:102
@ fa_sludge
Definition: treatment.h:68
@ fp_liquidNH3
Definition: treatment.h:51
@ spring_roll
Definition: treatment.h:46
@ fa_greenmanure
Definition: treatment.h:67
@ spring_plough
Definition: treatment.h:44
@ molluscicide
Definition: treatment.h:75
@ syninsecticide_treat
Definition: treatment.h:99
@ hay_turning
Definition: treatment.h:88
@ autumn_roll
Definition: treatment.h:38
@ fp_manure
Definition: treatment.h:55
@ deep_ploughing
Definition: treatment.h:43
@ pigs_out
Definition: treatment.h:84
@ fa_npk
Definition: treatment.h:61
@ herbicide_treat
Definition: treatment.h:71
@ row_cultivation
Definition: treatment.h:76
@ spring_sow
Definition: treatment.h:47
@ fungicide_treat
Definition: treatment.h:73
@ fp_manganesesulphate
Definition: treatment.h:53
@ harvest
Definition: treatment.h:82
@ cut_to_silage
Definition: treatment.h:86
@ sleep_all_day
Definition: treatment.h:33
@ mow
Definition: treatment.h:93
@ fa_ammoniumsulphate
Definition: treatment.h:65
@ autumn_plough
Definition: treatment.h:34
@ straw_chopping
Definition: treatment.h:87
@ fa_manure
Definition: treatment.h:66
@ fp_greenmanure
Definition: treatment.h:56
@ fa_slurry
Definition: treatment.h:63
@ product_treat
Definition: treatment.h:101
@ stubble_harrowing
Definition: treatment.h:90
@ hilling_up
Definition: treatment.h:79
@ growth_regulator
Definition: treatment.h:72
@ insecticide_treat
Definition: treatment.h:74
@ cattle_out_low
Definition: treatment.h:100
@ cut_to_hay
Definition: treatment.h:85
@ cut_weeds
Definition: treatment.h:94
@ fp_sludge
Definition: treatment.h:57
@ autumn_sow
Definition: treatment.h:41
@ fp_npk
Definition: treatment.h:49
@ fp_pk
Definition: treatment.h:50
@ hay_bailing
Definition: treatment.h:89
@ spring_harrow
Definition: treatment.h:45
@ strigling_sow
Definition: treatment.h:95
@ cattle_out
Definition: treatment.h:83
@ fp_slurry
Definition: treatment.h:52
@ water
Definition: treatment.h:80
@ autumn_or_spring_plough
Definition: treatment.h:91

References autumn_harrow, autumn_or_spring_plough, autumn_plough, autumn_roll, autumn_sow, burn_straw_stubble, cattle_out, cattle_out_low, cfg_par_ad_cut, cut_to_hay, cut_to_silage, cut_weeds, deep_ploughing, Landscape::EventtypeToString(), fa_ammoniumsulphate, fa_greenmanure, fa_manure, fa_npk, fa_pk, fa_sludge, fa_slurry, fp_greenmanure, fp_liquidNH3, fp_manganesesulphate, fp_manure, fp_npk, fp_npks, fp_pk, fp_sludge, fp_slurry, fungicide_treat, g_rand_uni, glyphosate, growth_regulator, harvest, hay_bailing, hay_turning, herbicide_treat, hilling_up, insecticide_treat, TAnimal::m_OurLandscape, Partridge_Base::m_state, MDying(), molluscicide, mow, pars_Destroy, pigs_out, product_treat, row_cultivation, sleep_all_day, spring_harrow, spring_plough, spring_roll, spring_sow, straw_chopping, strigling, strigling_sow, stubble_harrowing, swathing, syninsecticide_treat, CfgFloat::value(), Landscape::Warn(), water, and winter_plough.

◆ OnFemaleGivingUp()

void Partridge_Male::OnFemaleGivingUp ( )

Message handler.

Response to a pcomm_FemaleGivingUp message received if the female gives up during territory finding.

2784 {
2785 #ifdef __PAR_DEBUG
2787 
2788 #endif
2789  m_MyMate = NULL;
2790  RemoveOldMate(false);
2792  m_covey->SetFixed( false );
2793 }

References CheckMatePointers(), Partridge_Base::m_covey, m_MyMate, Partridge_Base::m_state, pars_MFlocking, RemoveOldMate(), and Partridge_Covey::SetFixed().

Referenced by Partridge_Communication::PassMessage().

◆ OnFoundATerrtitory()

void Partridge_Male::OnFoundATerrtitory ( )

Message handler.

◆ OnLookAfterKids()

void Partridge_Male::OnLookAfterKids ( void  )

Message handler.

Response to pcomm_EggsHatch message arriving on clutch hatching.

2676 {
2677  // He doesn't actually do anything, just records that fact that this is
2678  // what his biological counterpart would be doing now.
2680 #ifdef __PAR_DEBUG
2682 #endif
2683 }

References CheckMatePointers(), Partridge_Base::m_state, and pars_MCaringForYoung.

Referenced by Partridge_Communication::PassMessage().

◆ OnMateDying()

void Partridge_Male::OnMateDying ( )

Message handler.

Response to a pcomm_MumDeadC message received when the female dies.

2762 {
2763 #ifdef __PAR_DEBUG
2765 
2766 #endif
2767  RemoveOldMate(false);
2768  m_MyMate = NULL;
2769  // This will send him to finding a mate if it is early, otherwise
2770  // indirectly to flocking unless he still has kids in which case he has to
2771  // look after them
2772  //
2773  if ( m_covey->GetOurChicks() == 0 ) m_state = pars_MFindingMate;
2774 }
int GetOurChicks()
Return the number of chicks.
Definition: Partridge_Covey.h:471

References CheckMatePointers(), Partridge_Covey::GetOurChicks(), Partridge_Base::m_covey, m_MyMate, Partridge_Base::m_state, pars_MFindingMate, and RemoveOldMate().

Referenced by Partridge_Communication::PassMessage().

◆ OnMating()

void Partridge_Male::OnMating ( Partridge_Female a_mate)

Message handler.

Arrives here following pcomm_MatingM message from Partridge_Population_Manager::DissolveCovey.

2739 {
2740 #ifdef __PAR_DEBUG
2741  if ( m_MyMate != NULL )
2742  {
2743  m_OurLandscape->Warn( "Partridge_Male::OnMating(): ""m_MyMate is not NULL on Mating", "" );
2744  exit( 1 );
2745  }
2746 #endif
2747  m_MyMate = a_mate;
2748  RemoveOldMate(false);
2750  SetFamily( m_MyMate->GetFamily() ); // synchronize families
2751 #ifdef __PAR_DEBUG
2753 #endif
2754 
2755 }
int GetFamily(void)
Supply family ID.
Definition: Partridge_All.h:467
void SetFamily(unsigned int family)
Set family ID.
Definition: Partridge_All.h:487

References CheckMatePointers(), Partridge_Base::GetFamily(), m_MyMate, TAnimal::m_OurLandscape, Partridge_Base::m_state, pars_MPairing, RemoveOldMate(), Partridge_Base::SetFamily(), and Landscape::Warn().

Referenced by Partridge_Communication::PassMessage().

◆ OnMovingHome()

void Partridge_Male::OnMovingHome ( void  )

Message handler.

A pcomm_MovingHome message from the female if she cannot find a nest location in the current 'territory'.

2730 {
2732 }

References Partridge_Base::m_state, and pars_MGuardingMate.

Referenced by Partridge_Communication::PassMessage().

◆ OnStoppingBreeding()

void Partridge_Male::OnStoppingBreeding ( void  )

Message handler.

Response to the pcomm_StoppingBreeding message, caused by the female giving up breeding.

2710 {
2711  m_MyMate = NULL;
2713 
2714 }

References m_MyMate, Partridge_Base::m_state, and pars_MFlocking.

Referenced by Partridge_Communication::PassMessage().

◆ RemoveOldMate()

void Partridge_Male::RemoveOldMate ( bool  a_knockon)

Forget any old mate.

Removes a memory of the old mate. If knockon is true this is reciprocal.

2661  {
2662  if (m_MyOldWife!= NULL) {
2663  if (!a_knockon) m_MyOldWife->RemoveOldMate(true);
2664  m_MyOldWife= NULL;
2665  }
2666  }
void RemoveOldMate(bool a_knockon)
Forget old mate.
Definition: Partridge_All.h:903

References m_MyOldWife, and Partridge_Female::RemoveOldMate().

Referenced by MDying(), OnFemaleGivingUp(), OnMateDying(), OnMating(), Partridge_Communication::PassMessage(), Partridge_Female::RemoveOldMate(), and StartBreedingBehaviour().

◆ SetOldMate()

void Partridge_Male::SetOldMate ( Partridge_Female pf)
inline

Set old mate pointer.

752  {
753  m_MyOldWife=pf;
754  }

References m_MyOldWife.

Referenced by Partridge_Female::FLaying().

◆ StartBreedingBehaviour()

void Partridge_Male::StartBreedingBehaviour ( void  )

Message handler.

Got this message from Partridge_Population_Manager::DissolveCovey because he has no mate and covey dissolve has happended.

2720 {
2722  RemoveOldMate(false);
2723 }

References Partridge_Base::m_state, pars_MFindingMate, and RemoveOldMate().

Referenced by Partridge_Population_Manager::DissolveCovey().

◆ Step()

void Partridge_Male::Step ( void  )
virtual

Male Step.

Male Step code is where all his behaviour is carried out.

Reimplemented from TAnimal.

2229 {
2230 #ifdef __PAR_DEBUG
2232 
2233 #endif
2234  if ( m_CurrentStateNo == -1 || m_StepDone )
2235  return;
2236  switch ( m_state )
2237  {
2238  case pars_Initiation:
2240  break;
2241  case pars_MFlocking:
2242  m_state = MFlocking();
2243  m_StepDone = true;
2244  break;
2245  case pars_MFindingMate:
2246  m_state = MFindingMate();
2247  m_StepDone = true;
2248  break;
2249  case pars_MPairing:
2250  m_state = MPairing();
2251  m_StepDone = true;
2252  break;
2253  case pars_MGuardingMate:
2254  m_state = MGuardingMate();
2255  m_StepDone = true;
2256  break;
2257  case pars_MCaringForYoung:
2259  m_StepDone = true;
2260  break;
2261  case pars_MDying:
2262  case pars_Destroy:
2263  m_StepDone = true;
2264  break;
2265  case pars_MFollowingMate:
2266  m_state = MFollowingMate();
2267  m_StepDone = true;
2268  break;
2269  default:
2270  m_OurLandscape->Warn( "Partridge_Male::Step - unknown pars type", NULL );
2271  exit( 1 );
2272  }
2273 #ifdef __PAR_DEBUG
2275 #endif
2276 }
Partridge_State MFindingMate(void)
State male finding mate.
Definition: Partridge_All.cpp:2499
Partridge_State MGuardingMate(void)
State male guarding mate.
Definition: Partridge_All.cpp:2605
Partridge_State MFollowingMate(void)
State male follow mate.
Definition: Partridge_All.cpp:2587
Partridge_State MCaringForYoung(void)
State male caring for young.
Definition: Partridge_All.cpp:2617
Partridge_State MFlocking(void)
State male flocking.
Definition: Partridge_All.cpp:2489
Partridge_State MPairing(void)
State male pairing.
Definition: Partridge_All.cpp:2576

References CheckMatePointers(), TALMaSSObject::m_CurrentStateNo, TAnimal::m_OurLandscape, Partridge_Base::m_state, TALMaSSObject::m_StepDone, MCaringForYoung(), MFindingMate(), MFlocking(), MFollowingMate(), MGuardingMate(), MPairing(), pars_Destroy, pars_Initiation, pars_MCaringForYoung, pars_MDying, pars_MFindingMate, pars_MFlocking, pars_MFollowingMate, pars_MGuardingMate, pars_MPairing, and Landscape::Warn().

◆ UnSetMate()

void Partridge_Male::UnSetMate ( void  )
inline

remove mate pointer

708  {
709  m_MyMate=NULL;
710  }

References m_MyMate.

Member Data Documentation

◆ m_lifespan

int Partridge_Male::m_lifespan
private

Physiological lifespan.

Referenced by BeginStep(), and Partridge_Male().

◆ m_MyMate

◆ m_MyOldWife

Partridge_Female* Partridge_Male::m_MyOldWife
private

Old mate pointer.

Referenced by GetOldMate(), Partridge_Male(), RemoveOldMate(), and SetOldMate().


The documentation for this class was generated from the following files: